package com.swak.frame.lock;

import java.util.concurrent.TimeUnit;

import org.springframework.beans.factory.InitializingBean;

public interface DistributedLock extends InitializingBean {
    /**
     * @param lockKey
     * @param requestId
     * @param waitTime
     * @param timeOutUnit
     * @return
     */
    public boolean tryLock(String lockKey, String requestId, long waitTime, TimeUnit timeOutUnit);

    /**
     * 外部调用加锁的方法
     * 
     * @param lockKey 锁的名字
     * @param timeout 超时时间（放置时间长度，如：5L）
     * @return
     */
    public boolean tryLock(String lockKey, String requestId);

    public boolean tryLock(String lockKey, String requestId, long seconds);

    /**
     * 释放锁
     * 
     * @param lockKey
     * @param requestId
     * @return
     */
    public boolean unLock(String lockKey, String requestId);
}
